<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
         "http://www.w3.org/TR/REC-html40/strict.dtd">
<?php



session_start();



include "modules/config/index.php";
include "modules/departments/index.php";

$last_page = $_SESSION["last_page"];


echo <<<STOP

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
STOP;
include "modules/seo/index.php";
echo <<<STOP
<link rel="shortcut icon" href="http://{$_SERVER['SERVER_NAME']}/images/favicon.ico" type="image/ico" />
<link href="http://{$_SERVER['SERVER_NAME']}/css/prc.css" type=text/css rel=stylesheet />
<link href="http://{$_SERVER['SERVER_NAME']}/css/grid.css" type=text/css rel=stylesheet />
<link href="http://{$_SERVER['SERVER_NAME']}/css/corners.css" type=text/css rel=stylesheet />
<link href="http://{$_SERVER['SERVER_NAME']}/css/menu.css" type=text/css rel=stylesheet />
<!--link href="http://{$_SERVER['SERVER_NAME']}/css/news.css" type=text/css rel=stylesheet /-->
<link href="http://{$_SERVER['SERVER_NAME']}/css/custom_mb.css" type=text/css rel=stylesheet />
<link href="http://{$_SERVER['SERVER_NAME']}/css/custom.css" type=text/css rel=stylesheet />
<link href="http://{$_SERVER['SERVER_NAME']}/css/009_search.css" type=text/css rel=stylesheet />


<script type="text/javascript" src="http://{$_SERVER['SERVER_NAME']}/modules/general/jquery-1.6.min.js"></script>

STOP;

if (isset($_SESSION["username"])) echo <<<STOP
<link rel="stylesheet" type="text/css" href="http://{$_SERVER['SERVER_NAME']}/modules/editor/js/cleditor/jquery.cleditor.css" />
<script type="text/javascript" src="http://{$_SERVER['SERVER_NAME']}/modules/editor/js/cleditor/jquery.cleditor.min.js"></script>
<script type="text/javascript" src="http://{$_SERVER['SERVER_NAME']}/modules/welcome/welcome.js"></script>
STOP;

include "modules/templates/index.php";


if (strtolower($area) == "ucp") $area = "UCP";
echo <<<STOP

<script type="text/javascript" src="http://{$_SERVER['SERVER_NAME']}/modules/general/json2.js"></script>

<script type="text/javascript" src="http://{$_SERVER['SERVER_NAME']}/modules/general/functions.js"></script>
<script type="text/javascript" src="http://{$_SERVER['SERVER_NAME']}/modules/menu/menu.js"></script>
<script type="text/javascript" src="http://{$_SERVER['SERVER_NAME']}/modules/news/scroll.js"></script>
<!--script language=javascript src="http://{$_SERVER['SERVER_NAME']}/modules/accessibility/zoom.js"></script-->
<script type="text/javascript">
var area = "{$area}";
var section = "{$section}";
var file = "{$file}";
window.sessionStorage.last_page = "{$last_page}";
</script>
</head>
<body class="body_{$section}">

STOP;
if(isset($_SESSION["username"])) echo <<<STOP
<div id="create_bar"><img id="create_image" src="/modules/admin/images/create_logo.png" alt="Create your content by dsquared"><div id="create_tag_line">create your content from dsquared</div></div>
STOP;

echo <<<STOP

<div id=page>
<div id=bg_left style=display:none class="bg_left_{$section} h_16 ">&nbsp;</div>
<div id=bg_right class="bg_right h_16 c_16">&nbsp;</div>
<div id=header >
STOP;
include "modules/header/index.php";
include "modules/accessibility/index.php";
echo <<<STOP
</div>
<div id=body >
STOP;

include "modules/menu/index.php";
include "modules/drag_and_drop/index.php";
//include "modules/accessibility/index.php";
$navsection = ($section != "main") ? $section : $area;
//if (basename($_SERVER['REQUEST_URI']) != "search.php") $navbar = navbar ($navsection);
//else $navbar = "";
$navbar = navbar ($navsection);

if (($area=="")&&($section=="main")) {
    include "modules/news/index.php";
}
include "modules/search_box/index.php";
include "modules/graphics/index.php";
include "modules/admin/index.php";



function show_content () {
    //global $check;
    //global $folders;
    global $file;
    
    //$url = "modules/articles/content/";
    //for ($f=1;$f<count($folders)-1;$f++) {
    //    $url = $url . $folders[$f] . "/";
    //}
    //$url = $url . $file;
    global $article;
		//if (isset($_SESSION["username"])) echo "<textarea style=width:100%;height:500px;>";
		if (isset($_SESSION["username"]) && file_exists($article . ".edit")) {
			 include $article. ".edit";
			 $_SESSION["edit_on"] = true;
	  } else if (file_exists($article)) {
			include $article;
			if(isset($_SESSION["edit_on"])) unset($_SESSION["edit_on"]);
		}
    else {
				 echo "<p>$file does not exist</p>";
				 if(isset($_SESSION["edit_on"])) unset($_SESSION["edit_on"]);
		}
		//if (isset($_SESSION["username"])) echo "</textarea>";
}

if (($area=="")&&($section=="main")) {
//    include "modules/news/index.php";
    include "modules/course_boxes/index.php";
    
    $class = "r_7 w_5_5 h_4";
    include "modules/welcome/index.php";
    
    $class = "social_media r_11 w_5_5 h_3 h_gutter";
    include "modules/social_media/index.php";
    
    $class = "video r_11 c_6_5 w_4_5_vidapp h_3 v_gutter h_gutter";
    include "modules/video/index.php";
    
    $class = "iphone r_11 c_11 w_4_5 h_3 v_gutter h_gutter";
    include "modules/iphone/index.php";
   // include "modules/course_boxes/index.php";
} else if ($area == "admin") {
    echo "<div class=\"r_6_75 c_1 w_7 content\">";
    echo "<div id=login_pane>Loading admin login...</div>";
    echo "<script language=javascript>do_login ();</script>";
    echo "</div>";
} else {
    include "modules/section_header/index.php";
    include "modules/info_bar/index.php";
    //$info_bar = "";
    if (basename($_SERVER['REQUEST_URI']) == "search.php") $info_bar =  show_info_bar("search","search","search.html");
    //else $info_bar = show_info_bar($area, $section, $file);
    else $info_bar = "";
    //
    //
    //echo "zz";
    //if (basename($_SERVER['REQUEST_URI']) == "search.php") $info_bar="Place Holder";
    
    if ($navbar) {
        $col = "c_5_25";
        $width = "w_11";
        if ($info_bar != "") $a_width = "w_6_5";
        else $a_width = "w_11";
    } else {
        $col = "c_1";
        $width = "w_15";
        if ($info_bar != "") $a_width = "w_11";
        else $a_width = "w_15";
    }
    echo "<div id=content class=\"r_6_75 {$col} {$width} content h_gutter\">";
    echo "<div id=content_text class=\"{$a_width}\" >";
    //global $file;
    //$file = basename($article);
    //echo "Ignore this I'm just testing: {$_SERVER['REQUEST_URI']}"; 
    //echo "<script type=text/javascript>alert('" . basename($_SERVER['REQUEST_URI']) . "')</script>";
    if (basename($_SERVER['REQUEST_URI']) == "search.php") include "modules/search_box/search.php";
    else if (basename($_SERVER['REQUEST_URI']) == "course_application.php") include "modules/course_application/index.php"; 
    else show_content ();
     // echo "file {$file}";
     
   
    echo "</div>";
    
    echo "</div>";
   // if (basename($_SERVER['REQUEST_URI']) == "search.php") {
    //	echo <<<STOP
    //	<div>
    //	Place Holder
    //	</div>
//STOP;
   // } else 
   if ($info_bar != "") echo $info_bar;
}
echo <<<STOP



</div>
STOP;
include "modules/footer/index.php";
echo <<<STOP
</div>


<script language="JavaScript" type="text/javascript">
show_menu("{$area}","{$section}");
set_height();
//zoom();

STOP;
if (file_exists($article . ".edit")) echo<<<STOP
show_toolbar_edit();
STOP;

if(isset($_SESSION["username"])) echo <<<STOP
move_toolbar();
STOP;

echo <<<STOP
</script>
    <script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-25209683-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</body>
</html>
STOP;
if(isset($_SESSION["username"])) include "modules/editor/index.php";
?>